package com.llu.jackson.poc.baseExp;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.llu.jackson.poc.baseExp.bean.Dna;
import com.llu.jackson.poc.baseExp.bean.Person;


public class MainTest {
    public static void main(String[] args) throws Exception {
        Person p = new Person();
//        p.age = 10;
//        p.name = "Alice";
//        // 此时Person 中是Object
//
//        p.object = new Dna();

        ObjectMapper mapper = new ObjectMapper();
//        mapper.enableDefaultTyping(ObjectMapper.DefaultTyping.JAVA_LANG_OBJECT);

//        String json = mapper.writeValueAsString(p);
        String json = "{\"age\":10,\"name\":\"Alice\",\"object\":[\"com.llu.jackson.poc.baseExp.bean.Dna\",{\"length\":100}]}";
        System.out.println(json);
        Person p2 = mapper.readValue(json, Person.class);
        System.out.println(p2);
    }
}
